package com.xuecheng.system.controller;

import com.xuecheng.commons.enums.ErrorCode;
import com.xuecheng.commons.model.vo.CompanyVo;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.commons.utils.AuthInfoHolder;
import com.xuecheng.commons.utils.JwtUtils;
import com.xuecheng.system.domain.Company;
import com.xuecheng.web.exceptions.BusinessException;
import io.jsonwebtoken.Claims;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xuecheng.system.service.CompanyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 * 教育机构前端控制器
 * </p>
 *
 * @author itheima
 */
@Slf4j
@RestController
@RequestMapping("/company")
public class CompanyController {

    @Autowired
    private CompanyService  companyService;

    @GetMapping("/mine")
    public ResponseResult<Company> mine() {
        //1.获取companyId
        Long companyId = AuthInfoHolder.getCompanyId();
        //2.调用service根据id查询信息
        Company company = companyService.getById(companyId);
        //3.构建输出对象，并返回
        CompanyVo companyVo = new CompanyVo();
        BeanUtils.copyProperties(company,companyVo);
        return ResponseResult.okResult(companyVo);
    }
}
